package Application.Controller;

import javafx.fxml.FXML;
import javafx.scene.control.Slider;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import Application.Tool.*;

import java.util.Random;

public class RandomPenSettingsController {
    @FXML Slider randomPenSettingSize;
    @FXML ComboBox<String> randomPenSettingMask;
    @FXML CheckBox AEnabled;
    @FXML CheckBox REnabled;
    @FXML CheckBox GEnabled;
    @FXML CheckBox BEnabled;
    @FXML Slider AMin, AMax;
    @FXML Slider RMin, RMax;
    @FXML Slider GMin, GMax;
    @FXML Slider BMin, BMax;

    @FXML public void onSizeChanged() {
        int size = (int)randomPenSettingSize.getValue();
        RandomPen.getInstance().setSize(size);
    }

    @FXML public void onMaskChanged() {
        String maskName = randomPenSettingMask.getValue();

        RandomPen.getInstance().setMask(maskName);
    }

    @FXML public void onAChanged() {
        boolean e = AEnabled.isSelected();
        int m = (int)AMin.getValue();
        int M = (int)AMax.getValue();

        if(m > M) {
            AMin.setValue(M);
        }

        RandomPen.getInstance().setA(e, m, M);
    }

    @FXML public void onRChanged() {
        boolean e = REnabled.isSelected();
        int m = (int)RMin.getValue();
        int M = (int)RMax.getValue();

        if(m > M) {
            RMin.setValue(M);
        }

        RandomPen.getInstance().setR(e, m, M);
    }

    @FXML public void onGChanged() {
        boolean e = GEnabled.isSelected();
        int m = (int)GMin.getValue();
        int M = (int)GMax.getValue();

        if(m > M) {
            GMin.setValue(M);
        }

        RandomPen.getInstance().setG(e, m, M);
    }

    @FXML public void onBChanged() {
        boolean e = BEnabled.isSelected();
        int m = (int)BMin.getValue();
        int M = (int)BMax.getValue();

        if(m > M) {
            BMin.setValue(M);
        }

        RandomPen.getInstance().setB(e, m, M);
    }

    public ComboBox<String> getCombo() {
        return randomPenSettingMask;
    }
}
